package io.renren.modules.generator.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.generator.entity.SalaryinfoEntity;
import io.renren.modules.generator.service.SalaryinfoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;




/**
 * 
 * 员工工资信息
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2017-10-13 22:43:30
 */
@RestController
@RequestMapping("/generator/salaryinfo")
public class SalaryinfoController {
	@Autowired
	private SalaryinfoService salaryinfoService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("generator:salaryinfo:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<SalaryinfoEntity> salaryinfoList = salaryinfoService.queryList(query);
		int total = salaryinfoService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(salaryinfoList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{salaryno}")
	@RequiresPermissions("generator:salaryinfo:info")
	public R info(@PathVariable("salaryno") String salaryno){
		SalaryinfoEntity salaryinfo = salaryinfoService.queryObject(salaryno);
		
		return R.ok().put("salaryinfo", salaryinfo);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("generator:salaryinfo:save")
	public R save(@RequestBody SalaryinfoEntity salaryinfo){
		salaryinfoService.save(salaryinfo);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("generator:salaryinfo:update")
	public R update(@RequestBody SalaryinfoEntity salaryinfo){
		salaryinfoService.update(salaryinfo);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("generator:salaryinfo:delete")
	public R delete(@RequestBody String[] salarynos){
		salaryinfoService.deleteBatch(salarynos);
		
		return R.ok();
	}
	
}
